KM.Camera = function( vpWidth, vpHeight )
{
    this._viewport = new KM.Viewport( vpWidth, vpHeight );
    
    this._projection = null;
    this._fov = null;
    this._near = null;
    this._far = null;
    
    this._transform = null;
    this._eye = null;
    this._target = null;
    this._up = null;
    
    this._dir = vec3.create();
};

KM.Camera.prototype = {
    constructor: KM.Camera,
    
    makePerspectiveProjection: function( iFov, iNear, iFar )
    {
        if( !this._projection ) this._projection = new KM.Transform();    
        
        this._projection.perspective( iFov, this._viewport._aspectRatio, iNear, iFar );
        
        this._fov = iFov;
        this._near = iNear;
        this._far = iFar;
    },
    
    lookAt: function( iEye, iTarget, iUp )
    {
        if( !this._transform ) this._transform = new KM.Transform();
        
        this._transform.lookAt( iEye, iTarget, iUp );
        this._eye = iEye;
        this._target = iTarget;
        this._up = iUp;
        
        vec3.subtract( this._target, this._eye, this._dir );
        vec3.normalize( this._dir );
        
//        if( KM.InputsManager.LOG ) console.log("InputsManager.js, lookAt() : eye: " + vec3.str( this._eye ) + ", dir: " + vec3.str( this._dir ) );
    },
    
    toString: function()
    {
        return "Camera : \n"
//            + "\t projection => " + this._projection.toString() + " \n"
            + "\t eye => " + vec3.str( this._eye ) + " \n"
            + "\t target => " + vec3.str( this._target ) + " \n"
            + "\t up => " + vec3.str( this._up ) + " \n"
//            + "\t transform => " + this._transform.toString() + " \n"
            + "\t viewport => " + this._viewport.toString();
    }
};
